package com.yzh.homework.homework06;

import java.util.Scanner;

/**
 * @author 于振晗
 * @title: Pizza
 * @description: TODO 披萨类
 * @date 2020年08月27日
 * @path com.yzh.homework.homework06
 */
public class Pizza {
    private String pizzaName;
    private double price;
    private int size;

    public Pizza(double price, int size) {
        this.price = price;
        this.size = size;
    }

    public void show(){
        System.out.println("价格:"+price+"元");
        System.out.println("大小:"+size+"寸");
    }
}

//培根类
class Bacon extends Pizza{
    private final String pizzaName = "培根披萨";
    //培根数量
    private int number;

    public Bacon(double price, int size, int number) {
        super(price, size);
        this.number = number;
    }

    @Override
    public void show(){
        System.out.println("名称:"+pizzaName);
        super.show();
        System.out.println("培根数量:"+number);
    }
}

//海鲜披萨
class Seafood extends Pizza{
    private final String pizzaName = "海鲜披萨";
    private String resources;

    public Seafood(double price, int size, String resources) {
        super(price, size);
        this.resources = resources;
    }

    @Override
    public void show(){
        System.out.println("名称:"+pizzaName);
        super.show();
        System.out.println("配料:"+resources);
    }
}

//披萨工厂类
class PizzaFactory{
    static Scanner in = new Scanner(System.in);
    public static Pizza getPizza(int num){
        if(num == 1){
            System.out.print("请输入培根克数:");
            int number = in.nextInt();
            System.out.print("请输入披萨大小:");
            int size = in.nextInt();
            System.out.print("请输入披萨价格:");
            double price = in.nextInt();
            return new Bacon(price,size,number);
        }else{
            System.out.print("请输入配料信息:");
            String resources = in.next();
            System.out.print("请输入披萨大小:");
            int size = in.nextInt();
            System.out.print("请输入披萨价格:");
            double price = in.nextInt();
            return new Seafood(price,size,resources);
        }
    }

    public static void main(String[] args) {
        System.out.print("请选择湘瑶制作的披萨(1.培根披萨 2.海鲜披萨)");
        int select = in.nextInt();
        Pizza pizza = PizzaFactory.getPizza(select);
        pizza.show();
    }
}